package com.qianxx.component.activity.menu.satellite_menu;

import android.os.Bundle;
import android.util.TypedValue;

import com.qianxx.component.R;
import com.qianxx.component.activity.base.BaseActivity;
import com.qianxx.viewlibrary.menu.satelitemenu.SatelliteMenu;
import com.qianxx.viewlibrary.menu.satelitemenu.SatelliteMenuItem;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

public class SatelliteMenuActivity extends BaseActivity {
    @BindView(R.id.satellite_menu)
    SatelliteMenu satelliteMenu;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_satellite_menu);
        ButterKnife.bind(this);

        // applyDimension()是将数值转变为标准尺寸：COMPLEX_UNIT_DIP是单位，170是数值，转变后就是170dip
        float distance = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
                170, getResources().getDisplayMetrics());
        // 设置菜单项与圆心间的距离
        satelliteMenu.setSatelliteDistance((int) distance);
        // 设置展开动画的持续时间
        satelliteMenu.setExpandDuration(500);
        // 禁用菜单项的点击事件
        satelliteMenu.setCloseItemsOnClick(false);
        // 设置菜单项间的夹角角度
        satelliteMenu.setTotalSpacingDegree(90);

        // 添加菜单项
        List<SatelliteMenuItem> items = new ArrayList<>();
        items.add(new SatelliteMenuItem(1, R.drawable.ic_1));
        items.add(new SatelliteMenuItem(2, R.drawable.ic_2));
        items.add(new SatelliteMenuItem(3, R.drawable.ic_3));
        items.add(new SatelliteMenuItem(4, R.drawable.ic_4));
        items.add(new SatelliteMenuItem(5, R.drawable.ic_5));
        items.add(new SatelliteMenuItem(6, R.drawable.ic_6));
        satelliteMenu.addItems(items);

        satelliteMenu.setOnItemClickedListener(new SatelliteMenu.SateliteClickedListener() {

            public void eventOccured(int id) {

            }
        });
    }

    @Override
    public String setTitle() {
        return "SatelliteMenu";
    }
}
